Ext.application({
    name: 'BioGene',
	viewport: { autoMaximize: true },
    requires: [
        'Ext.MessageBox'
    ],

	models: ["GeneInfo",'GeneRifs','GeneRifsView'],
	stores: ['GeneStore','GeneRifStore'],
	controllers: ['BioGene'],
    views: ['InformationView','SearchIndexView','SettingsView','GeneView','AbstractView','SearchListView'],

    icon: {
        57: 'resources/icons/Icon.png',
        72: 'resources/icons/Icon~ipad.png',
        114: 'resources/icons/Icon@2x.png',
        144: 'resources/icons/Icon~ipad@2x.png'
    },
    
    phoneStartupScreen: 'resources/loading/Homescreen.jpg',
    tabletStartupScreen: 'resources/loading/Homescreen~ipad.jpg',

    launch: function() {
        // Destroy the #appLoadingIndicator element
        //Ext.fly('appLoadingIndicator').destroy();
        //Ext.fly('appLoadingContainer').destroy();
        Ext.fly('appLoadingBG').destroy();
        
        if (!getCookie('bg_results') || !getCookie('bg_organism') || !getCookie('bg_references')) {
    		setCookie('bg_organism','human',365);
    		setCookie('bg_references',20,365);
    		setCookie('bg_results',10,365);
    	}
    	
    	if (!getCookie('bg_font_scale')) {
    		setCookie('bg_font_scale',0,365);
    	}

        // Initialize the main view
        var searchIndexView = {
        	xtype: "searchindexview"
        };
         var informationView = {
        	xtype: "informationview"
        };
        var settingsView = {
        	xtype: "settingsview"
        };
        var geneView = {
        	xtype: "geneview"
        };
        var abstractView = {
        	xtype: "abstractview"
        };
        var searchListView = {
        	xtype: "searchlistview"
        };
        Ext.Viewport.add([searchIndexView, settingsView, informationView, geneView, abstractView, searchListView]);
    	$(document).ready(function(){
   			$('span.mailme').mailme();
		});
    },

    onUpdated: function() {
        Ext.Msg.confirm(
            "Application Update",
            "This application has just successfully been updated to the latest version. Reload now?",
            function(buttonId) {
                if (buttonId === 'yes') {
                    window.location.reload();
                }
            }
        );
    }
});
